var app = getApp()
var modal = require('../../utils/modal');
var request = require('../../utils/request');
var utils = require('../../utils/utils');
var commodity = require('../widget/commodityDisplay/commodityDisplay');
var storage = require('../../utils/storage');

var shareContent = {
    'title':'企鹅优品-优质生活指南',
    'desc':'腾讯精品体验平台，为用户提供优质的生活方式和购物体验。',
    'path':'/pages/project-index/index'
}
var shareObj = utils.share(shareContent);
var pageSetting = {
    data: {
        lists:[{},{},{}]
    },
    onLoad: function(options) {

        var categoryName = options.categoryName;
        var categoryId = options.categoryId;      
        wx.setNavigationBarTitle({
           title: categoryName
        })

        var that = this;

        var categoryData = {
            "self:Goods:Category:getCategoryGoodsList":{
                agencyId:"10000016",
                categoryId:categoryId
            }
        }
        /*为组件填充数据*/
        var tempCommodity = that.data['comCommodity'];

        request.post({
            path: '/wxapp_api/api'
        },categoryData)
            .then(function(res){
                var data = res['self:Goods:Category:getCategoryGoodsList'];
                if (data.ret != 0){
                    // modal.toast(retData.msg);
                    wx.navigateTo({
                        url: "../error/error"
                    })
                    return false;
                }

                tempCommodity.data.list = data.data;
                
                that.setData({
                    comCommodity:tempCommodity
                });

            });
    }
};

utils.assign(pageSetting,shareObj,commodity);
Page(pageSetting);
